package cn.j0n4than.accountingtool.service.impl;

import cn.j0n4than.accountingtool.entity.Active;
import cn.j0n4than.accountingtool.mapper.ActiveMapper;
import cn.j0n4than.accountingtool.service.ActiveService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 激活服务接口实现
 *
 * @author jonathan
 */
@Service
public class ActiveServiceImpl extends ServiceImpl<ActiveMapper, Active> implements ActiveService {

    /**
     * 插入数据
     *
     * @param active active实例
     * @return 影响行数
     */
    @Override
    public Integer insert(Active active) {
        return this.baseMapper.insert(active);
    }

    /**
     * 更新用户
     *
     * @param active active实例
     * @return 影响行数
     */
    @Override
    public Integer update(String id, Active active) {
        UpdateWrapper<Active> activeUpdateWrapper = new UpdateWrapper<>();
        activeUpdateWrapper.eq("id", id);
        return this.baseMapper.update(active, activeUpdateWrapper);
    }

    /**
     * 通过ID找到这条数据
     *
     * @param id 激活ID
     * @return Active
     */
    @Override
    public Active getActiveById(String id) {
        return this.baseMapper.selectById(id);
    }
}
